1866A - Ambitious Kid - CodeForces Solution


math

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
#include <algorithm> //__gcd(a,b);
using namespace std;


void setIO(string s) {
    ios_base::sync_with_stdio(0); cin.tie(0); 
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
}

using ll = long long;
using ld = long double;
using db = double;
using str = string;

typedef long long ll;
typedef vector<ll> vl; 
typedef vector<int> vi;
typedef vector<pair<ll,ll>> vpl; 
typedef vector<pair<int, int>> vpi; 
typedef pair<int, int> pi;
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x) //will not work for bool
#define travBool(a,x) for (auto a: x)
#define print(x) trav(a,x){cout<<a<<" ";}cout<<endl; //will not work for bool
#define printPair(x) trav(a,x){cout<<"{"<<a.first<<" "<<a.second<<"} ";}cout<<endl; //will not work for bool
#define printBool(x) travBool(a,x){cout<<a<<" ";}cout<<endl;
#define print2d(x) trav(a,x){trav(b,a){cout<<b<<" ";}cout<<endl;}
#define print2dBool(x) trav(a,x){travBool(b,a){cout<<b<<" ";}cout<<endl;}
#define doPrefixSum2d(data, prefixSum,x,y){prefixSum.resize(x,vector<ll>(y,0));F0R(i,x){prefixSum[i][0]=0;}F0R(j,y){prefixSum[0][j]=0;}FOR(i,1,x){FOR(j,1,y){prefixSum[i][j]=data[i][j]+prefixSum[i-1][j]+prefixSum[i][j-1]-prefixSum[i-1][j-1];}}}//x and y are the size of prefixSum and data including the first row of 0s
#define printQueue(q){auto copyOfQ=q;if(copyOfQ.empty()){cout<<"empty";}while(!copyOfQ.empty()){cout<<copyOfQ.front()<<" ";copyOfQ.pop();}cout<<endl;}
#define printDeque(q){auto copyOfQ=q;if(copyOfQ.empty()){cout<<"empty";}while(!copyOfQ.empty()){cout<<copyOfQ.front()<<" ";copyOfQ.pop_front();}cout<<endl;}
#define printDequePair(q){auto copyOfQ=q;if(copyOfQ.empty()){cout<<"empty";}while(!copyOfQ.empty()){cout<<"{"<<copyOfQ.front().first<<" "<<copyOfQ.front().second<<"} ";copyOfQ.pop_front();}cout<<endl;}
#define printStack(q){auto copyOfQ=q;if(copyOfQ.empty()){cout<<"empty";}while(!copyOfQ.empty()){cout<<copyOfQ.top()<<" ";copyOfQ.pop();}cout<<endl;} //printed backwards, last in first out occurs first in the print


#define pb push_back
#define pf push_front //for deques
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define f first
#define s second

const int MOD = 1e9+7; // 998244353; //this is a completely different unrelated prime number
//const __int128 MOD = 13000000000000019; prime number, for hashing shit
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const ld PI = acos((ld)-1);

bool debug=false;
bool ysort(const pair<ll,ll>& x, const pair<ll,ll>& y){
    return x.s<y.s;
}

void solve() {
    int n; cin >> n;
    vi a(n); F0R(i, n) cin >> a[i];
    int ans = INT_MAX;
    F0R(i, n) {
        ans = min(ans, abs(a[i]));
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    // cin >> t;
 
    while (t--) {
        solve();
    }
 
    return 0;
}


Comments

Submit
0 Comments
More Questions

810B - Summer sell-off
84A - Toy Army
185A - Plant
1749A - Cowardly Rooks
1749C - Number Game
1749B - Death's Blessing
1749D - Counting Arrays
1447B - Numbers Box
1594D - The Number of Imposters
984B - Minesweeper
837A - Text Volume
1566C - MAX-MEX Cut
1546A - AquaMoon and Two Arrays
897B - Chtholly's request
1363B - Subsequence Hate
437B - The Child and Set
1256B - Minimize the Permutation
733B - Parade
172A - Phone Code
148D - Bag of mice
421A - Pasha and Hamsters
1393A - Rainbow Dash Fluttershy and Chess Coloring
980E - The Number Games
219B - Special Offer Super Price 999 Bourles
560B - Gerald is into Art
322B - Ciel and Flowers
801B - Valued Keys
975C - Valhalla Siege
518B - Tanya and Postcard
514B - Han Solo and Lazer Gun